package com.example.utils;

import com.amap.api.location.core.e;

import android.content.Context;
import android.content.SharedPreferences.Editor;

public class ShareUtils {

	private static final String FILE_NAME = "dianping";
	private static final String MODE_NAME = "welcome";
	private static final String CITY_NAME = "cityName";

	public static boolean getSharePreferences(Context context) {
		return context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
				.getBoolean(MODE_NAME, false);
	}

	public static void setSharePreferences(Context context, boolean value) {
		Editor editor = context.getSharedPreferences(FILE_NAME,
				Context.MODE_APPEND).edit();

		editor.putBoolean(MODE_NAME, value);
		editor.commit();

	}

	// put the city name
	public static String getCityName(Context context) {
		return context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
				.getString(CITY_NAME, "请选择一个城市");
	}

	// get the city name
	public static void setCityName(Context context, String value) {
		Editor editor = context.getSharedPreferences(FILE_NAME,
				Context.MODE_APPEND).edit();
		editor.putString(CITY_NAME, value);
		editor.commit();

	}

	// save the username
	public static void putUserName(Context context, String userName) {
		Editor editor = context.getSharedPreferences(FILE_NAME,
				Context.MODE_APPEND).edit();
		editor.putString("userName", userName);
		editor.commit();
	}

	// put the username
	public static String getUserName(Context context) {
		return context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
				.getString("userName", "点击登录");
	}

}